package com.bleeth.fx.component;

import com.bleeth.fx.helper.SStyleHelper;
import com.bleeth.fx.helper.StyleHelper;
import com.bleeth.fx.layout.FormBuilder;
import com.bleeth.fx.layout.GirdCell;
import javafx.geometry.Pos;
import javafx.scene.control.TextField;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import lombok.Builder;


/**
 * @author Sakura
 * @version 1.0
 * @date 2021-11-13 22:17
 **/
@Builder
public class MInput {

    private String icon;

    @Builder.Default
    private double height = 40;

    @Builder.Default
    private double width = 300;

    @Builder.Default
    private String placeholder = "";

    public Region make() {
        TextField textField = new TextField();
        Region iconNode = MIcon.builder().icon(icon).size(20).build().make();

        VBox box = FormBuilder.form(width, height, Pos.CENTER)
                .coverRow(GirdCell.createCell(1, Pos.CENTER),
                        GirdCell.createCell(30D, Pos.CENTER))
                .coverCell(0, textField)
                .addCell(1, iconNode)
                .endRow(false)
                .build();


        //textField 移除边框
        textField.setStyle("-fx-background-color: #ebebeb");
        StyleHelper.ft(textField).size(24).make();
        textField.setPromptText(placeholder);
        SStyleHelper.node(box)
                .addStyle("-fx-border-width", "0 0 2 0")
                .addStyle("-fx-border-style", "solid")
                .addStyle("fx-border-color", "#000000")
                .apply();
        System.err.println("placeholder = " + placeholder);
        return box;
    }

}
